package com.cwf.system.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.cwf.common.entity.page.PageEntity;
import com.cwf.system.entity.Role;
import lombok.*;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;


@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class RolePageListVO  {

    /**
     * 角色id
     */
    @TableId(type = IdType.AUTO)
    @Null(groups = ValidGroup.Crud.Create.class, message = "不需要填写id")
    @NotNull(groups = ValidGroup.Crud.Update.class,message = "id不能为空")
    @NotNull(groups = ValidGroup.Crud.Delete.class,message = "id不能为空")
    private Long roleId;
    /**
     * 角色名称
     */
    @NotNull(groups = ValidGroup.Crud.Create.class, message = "角色名称不能为空")
    @Length(max = 10)
    private String roleName;
    /**
     * 角色描述
     */
    @NotNull(groups = ValidGroup.Crud.Create.class, message = "角色描述不能为空")
    @Length(max = 100)
    private String roleDesc;
    /**
     * 状态
     */
    @NotNull(groups = ValidGroup.Crud.Create.class, message = "角色状态不能为空")
    private Integer state;

    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 最后编辑人id
     */
    private Long editUserId;
    /**
     * 创建者id
     */
    private Long creatorId;

    public static RolePageListVO toVO(Role role){
        RolePageListVO rolePageListVO = new RolePageListVO();
        rolePageListVO.setRoleId(role.getRoleId());
        rolePageListVO.setRoleName(role.getRoleName());
        rolePageListVO.setRoleDesc(role.getRoleDesc());
        rolePageListVO.setState(role.getState());
        rolePageListVO.setEditUserId(role.getEditUserId());

        return rolePageListVO;

    }


}
